﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.BLL;
using HZ.MBSM.Model;
using HZ.MBSM.DBUtility;

public partial class Agency_Traprojectlist : System.Web.UI.Page, IPageDescribe
{
    private string _Type = "";
    private DataTable dt;
    protected void Page_Load(object sender, EventArgs e)
    {

        if (HZ.MBSM.BLL.Login.CheckAssert(this.UseAccountType))
        {
            GetProjectData();
        }
    }

    public void GetProjectData()
    {

        Int64 AccountId = 0;
        HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
        if (_Account != null)
        {
            AccountId = SysFun.ToLong(_Account.AccountId);
            _Type = _Account.Type;
            string strselect = "select AccountId_father from AgencyChild where accountid=" + AccountId;
            Db db = new Db();
            DataTable dtt = db.DataTable(strselect);
            db.Close();
            if ((dtt != null) && (dtt.Rows.Count > 0))
            {
                AccountId = SysFun.ToLong(dtt.Rows[0][0]);
            }
        }
        AgencyBiding Agb = new AgencyBiding();
        dt = Agb.GetBidProjectDataTable(AccountId);

        GridView1.DataSource = dt.DefaultView;
        GridView1.DataBind();
        //dt.Dispose();
        //db.Close();
    }

    #region IPageDescribe 成员


    public string Describe
    {
        get { return "进入项目"; }
    }
    public string Name
    {
        get { return "进入项目"; }
    }
    public string ParentName
    {
        get { return "交易项目列表"; }
    }

    public System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> UseAccountType
    {
        get
        {
            System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAttorney);
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumSupplyCompanyCheck);
            return _AccountType;
        }
    }

    #endregion




    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if ((e.Row.RowType != DataControlRowType.Header) && (e.Row.RowType != DataControlRowType.Footer))
        {
            HyperLink hl = (HyperLink)e.Row.FindControl("HyperLink1");
            hl.Text = dt.Rows[e.Row.RowIndex][1].ToString();

            if (_Type == "1")
                hl.NavigateUrl = "TraTradeDataList.aspx?ProjectId="+dt.Rows[e.Row.RowIndex][0].ToString();
            if (_Type == "14")
                hl.NavigateUrl = "TraCheckIsbidcompany_PSM.aspx?ProjectId=" + dt.Rows[e.Row.RowIndex][0].ToString();
        }
    }
}

